/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands;

/**
 * This exception is raised by XRENewCommandHandler if it can not create the XREObject(e.g. if creation failed or the
 * created Object is not a valid XREObject).
 * <p>
 * Note the exception will only be propagated to XREAggregateCommandHandler and then processed by
 * XRECommandErrorHandler. It extends XREObjectCommandHandlerException.
 * <p>
 * <b>Thread Safety:</b> This class is not thread safe as its base class is not thread safe.
 *
 * @author liuliquan, 7realm
 * @version 1.0
 */
public class XREObjectCreationException extends XREObjectCommandHandlerException {
    /** Serial version UID. */
    private static final long serialVersionUID = -2422887125467891162L;

    /**
     * The klass failed to create a valid XREObject.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final String failedKlass;

    /**
     * Creates a new instance of XREObjectCreationException with given error message and the klass failed to create a
     * valid XREObject.
     *
     * @param message the error message
     * @param failedKlass the klass failed to create a valid XREObject
     */
    public XREObjectCreationException(String message, String failedKlass) {
        super(message);
        this.failedKlass = failedKlass;
    }

    /**
     * Creates a new instance of XREObjectCreationException with given error message, the cause and the klass failed to
     * create a valid XREObject.
     *
     * @param message the error message
     * @param cause the cause of the exception
     * @param failedKlass the klass failed to create a valid XREObject
     */
    public XREObjectCreationException(String message, Throwable cause, String failedKlass) {
        super(message, cause);
        this.failedKlass = failedKlass;
    }

    /**
     * Gets the class failed to create a valid XREObject.
     *
     * @return the class failed to create a valid XREObject
     */
    public String getFailedKlass() {
        return failedKlass;
    }
}